<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const className = {
            name: "No.1",
            person: [
                "小明",
                "小红",
                "小黑",
                "小白"
            ],
            // 自定义遍历className的时候遍历person
            [Symbol.iterator]() {
                let index = 0;
                return {
                    next: () => {
                        if (index < this.person.length) {
                            const result = { value: this.person[index], done: false };
                            index++;
                            return result;
                        } else {
                            return { value: undefined, done: true };
                        }
                    }

                }
            }
        }
        for (let value of className) {
            console.log(value);

        }
    </script>

</body>

</html>